Create an HttpRequest.
body | uint8[]|int8[]|char[] | The payload. This is the actual message that is to be sent. |
CompletedCallback | @(event) | Callback triggered when the request has finished sucessfully. |
connecttimeout | integer default value 5000 | Milliseconds for connection timeout. |
ExceptionOccurredCallback | @(obj, event) | Callback triggered when the request failed. |
headers | cellstr with name-value pairs. | The request headers. See for example: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers |
InitializedCallback | @(obj, event) | Callback triggered when the request is sent. |
method | string | The http request method, See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods |
parameters | cellstr with name-value pairs. | The query parameters. See for example: https://en.wikipedia.org/wiki/Query_string |
ProgressUpdatedCallback | @(obj, event) | Callback triggered when the server returns a progress update. |
proxyAddress | string | The url of the proxyserver. |
proxyPort | integer | The port of the proxy server. |
timeout | integer default value: 5000 | Milliseconds for response timeout. |
url | string | The destination url. |
Create an HttpRequest.
obj = HttpRequest(method, url, varargin)
method | string | The http method, e.g. 'POST', 'GET' or 'PUT' See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods |
url | string | The destination url. |
varargin | (string,any)[] | Parameter-value pairs corresponding to the HttpRequest properties. |
obj | modelit.web.client.HttpRequest | Documentation for modelit.web.client.HttpRequest/HttpRequest doc modelit.web.client.HttpRequest |
Evaluate a Matlab function remotely and asynchronously.
varargout = feval_async(obj, fp_final, fp, varargin)
obj | modelit.web.client.HttpRequest | |
fp_final | functionhandle | The function to be evaluated locally after the remote evaluation has finished. |
fp | functionhandle | The function to be evaluated remotely. |
varargin | any | The arguments. |
varargout | any | The outputs of the function evaluation. |
h = modelit.web.client.HttpRequest('GET','http://localhost:4444') disp(sprintf('%d',10)) % where "sprintf('%d',10)" is executed remotely feval_async(h,@disp,@sprintf,'%d',10)
Evaluate a Matlab function remotely.
varargout = feval(obj, fp, varargin)
obj | modelit.web.client.HttpRequest | |
fp | functionhandle | The function to be evaluated remotely. |
varargin | any | The arguments. |
varargout | any | The outputs of the function evaluation. |
h = modelit.web.client.HttpRequest('GET','http://localhost:4444') [tf,f] = feval(h,@find,[false, true]) N=0; for k=1:100, N = N+(feval(h,@randn,1)>0); end disp(N)
Set username and password for authenticated request.
obj = setCredentials(obj, username, password)
obj | modelit.web.client.HttpRequest | |
username | string | The username. |
password | string | The password. |
obj | modelit.web.client.HttpRequest |
Set the milliseconds before a response timeout.
obj = setTimeOut(obj, timeout)
obj | modelit.web.client.HttpRequest | |
timeout | integer | Milliseconds before response timeout. |
obj | modelit.web.client.HttpRequest |
Set the milliseconds before a connection timeout.
obj = setConnectTimeOut(obj, timeout)
obj | modelit.web.client.HttpRequest | |
connecttimeout | integer | Milliseconds before failover due to connection timeout. |
obj | modelit.web.client.HttpRequest |
Set the proxy address.
obj = setProxy(obj, proxyAddress, proxyPort))
obj | modelit.web.client.HttpRequest | |
proxyAddress | string | The proxy address. |
proxyPort | integer | The proxy port. |
obj | modelit.web.client.HttpRequest |
The http method, e.g. 'POST', 'GET' or 'PUT'
obj = setMethod(obj, method)
obj | modelit.web.client.HttpRequest | |
method | string | The http method, e.g. 'POST', 'GET' or 'PUT' See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods |
obj | modelit.web.client.HttpRequest |
Add one or more query parameters.
obj = addParameters(obj, varargin)
obj | modelit.web.client.HttpRequest | |
varargin | string, string | parameter, value pairs. E.g. 'q', '1' |
obj | modelit.web.client.HttpRequest |
Set the query parameters. The query parameters are attached to the end of a url after the '?'. E.g. https://www.google.com/search?q=abstract.
obj = setParameters(obj, parameters)
obj | modelit.web.client.HttpRequest | |
parameters | cellstring | name-value pairs with the query parameters. |
obj | modelit.web.client.HttpRequest |
Add one or more request headers.
obj = setUrl(obj, varargin)
obj | modelit.web.client.HttpRequest | |
varargin | string | header-value pairs, e.g. 'Content-Type', 'text/html' See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers |
obj | modelit.web.client.HttpRequest |
Set the request headers. The HTTP headers can be used in an HTTP request to provide information about the request context.
obj = setUrl(obj, url)
obj | modelit.web.client.HttpRequest | |
headers | cell[] | The request headers in name-value pairs. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers |
obj | modelit.web.client.HttpRequest |
Set the destination url.
obj = setUrl(obj, url)
obj | modelit.web.client.HttpRequest | |
url | string | The destination url. e.g. https://www.httpbin.org/get |
obj | modelit.web.client.HttpRequest |
Set the contents of the request Body. This is the actual data to be sent to the endpoint.
obj = setBody(obj, body)
obj | modelit.web.client.HttpRequest | |
body | int8[]|uint8[]|char[] | The data of the request body. |
obj | modelit.web.client.HttpRequest |
Evaluate the Completed callback.
callback(obj, event)
obj | modelit.web.client.HttpRequest | |
event | nl.modelit.web.client.CompletionEvent |
no output
Add the callbacks defined in the Matlab object to the java object.
obj = addCallbacks(obj)
obj | modelit.web.client.HttpRequest |
obj | modelit.web.client.HttpRequest | callbacks defined in the Matlab object are added to the java object. |
Get the java object which extends the Callable interface.
callable = getCallable(obj)
obj | modelit.web.client.HttpRequest |
callable | modelit.web.concurrent.Callable |
Set the callback to be executed when the client has received the complete response from the server.
setProgressUpdatedCallback(obj, callback)
obj | modelit.web.client.HttpRequest | |
callback | @(obj, event) | Use event.getProgress to get the progress (values between 0 and 100). |
obj | modelit.web.client.HttpRequest |
Set the callback to be executed when the server returns an error.
obj = setExceptionOccurredCallback(obj, callback)
obj | modelit.web.client.HttpRequest | |
callback | @(obj, event) | Callback executed when the server returns an error. |
obj | modelit.web.client.HttpRequest |
Set the callback to be executed when the client starts sending the request.
obj = setInitializedCallback(obj, callback)
obj | modelit.web.client.HttpRequest | |
callback | @(obj, event) | Callback executed when the client start sending the request. This is useful in combination with the modelit.web.concurrent.ThreadPoolExecutor to detect when a submitted request is executed. |
obj | modelit.web.client.HttpRequest |
Set the callback to be executed when the client has received the complete response from the server.
obj = setCompletedCallback(obj, callback)
obj | modelit.web.client.HttpRequest | |
callback | @(obj) | Callback executed when the request has completed. i.e. the complete response has been received. obj is a modelit.web.client.HttpResponse |
obj | modelit.web.client.HttpRequest |
Send the request. This method is asynchronous when a CompletedCallback is specified.
response = send(obj)
obj | modelit.web.client.HttpRequest |
response | [] | modelit.web.client.HttpResponse |
Assert that no error occured on remote computer.